<template>
  <view class="page-container">
    <view class="main-container">
      <view class="form-container">
        <view class="item">
          <textarea class="text-body" v-model="message" name="" id="" cols="30" rows="10" minlength="10" maxlength="1000"></textarea>
          <view class="ctrls">
            <view class="camera" @click="uploadImg">
              <img src="~@/static/other_slices/active_camera_icon.png" alt="">
            </view>
            <view class="tip">最多输入 1,000 字</view>
          </view>
        </view>
        <view v-if="uploadImgSrc" class="item">
          <img :src="uploadImgSrc" alt="" style="width: 100%;">
        </view>
        <view class="item">
          <button type="button" @click="submit" class="btn-res">立即预约</button>
        </view>
      </view>
    </view>
  </view>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
  data() {
    return {
      message:'',
      uploadImgSrc: ""
    }
  },
  methods: {
    uploadImg() {
      uni.chooseImage({
        count: 1,
        sourceType: ['camera'],
        success: (res) => {
          this.uploadImgSrc = res.tempFilePaths[0];
        }
      });
    },
    submit() {
      if( this.message.length < 10)
      {
        uni.showModal({
          title: "提示",
          content: "请至少输入10个文字",
        })
      }else {
        uni.showModal({
          title: "提示",
          content: "提交成功",
          showCancel: false,
          success: () => {
            this.uploadImgSrc = ""
            this.message=""
          }
        })
      }
    }
  }
})
</script>
<style lang="scss" scoped>
.page-container {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #efefef;
  display: flex;
  flex-direction: column;
}

.header-container {
  color: #fff;
  height: 24px;
  padding: 15px;
  flex-shrink: 0;
  display: flex;
  background: #006b65;
}

.header-container .left,
.header-container .right {
  font-size: 16px;
  width: 100px;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-container .center {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.main-container {
  flex-grow: 1;
  overflow: auto;
}

.form-container {
  padding: 7px;
  display: flex;
  flex-direction: column;

  .label {
    color: #333;
    font-size: 16px;
  }

  .item {
    textarea {
      width: 100%;
      height: 400px;
      border-color: transparent;
      border-radius: 15px;
      background: #ffffff;
    }
    .ctrls {
      display: flex;
      justify-content: space-between;
      margin-top: 20px;

      .camera {
        width: 50px;
        height: 50px;

        img {
          width: 100%;
          height: 100%;
        }
      }

      .tip {
        color: #666666;
        font-size: 13px;
        line-height: 50px;
      }
    }
  }
}
.text-body{
  //padding: 8px;
  margin-top: 10px;
}
.title-18{
  font-size:18px;
  font-weight: 500;
  text-align: center;
}
.btn-res{
  margin-top: 20px;
  background: #007aff;
  color: #fff;
}
</style>
